package com.cai.servlet.item;

import com.cai.dao.GoodsDao;
import com.cai.dao.impl.GoodsDaoImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * @author RuoLi
 */
@WebServlet(name = "ServletItemTypeDelete", value = "/itemTypeDelete")
public class ServletItemTypeDelete extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String itemTypeName = request.getParameter("itemTypeName");
        GoodsDao goodsDao = new GoodsDaoImpl();
        int code = goodsDao.deleteItemTypeName(itemTypeName);
        if (code != 0) {
            response.getWriter().println(1);
        } else {
            response.getWriter().println(0);
        }

    }
}
